home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 3: CDPD 3 / Almathera Ten on Ten - Disc 3: CDPD3.iso / scope / 201-220 / scopedisk214 / skeleton / dispatch.c < prev    next >
C/C++ Source or Header  |  1995-03-19  |  1KB  |  67 lines

  1. /*
  2.  * dispatch.c - C source file for Class dispatcher function.
  3.  *
  4.  *
  5.  * Public Domain
  6.  *
  7.  */
  8.  
  9. #include <skeleton_internal.h>
  10. #include <skeleton.h>
  11. #include <classglue.h>
  12.  
  13. ULONG __saveds __asm Skeleton_dispatch(    register __a0 Class * class,
  14.                                              register __a2 Object *obj,
  15.                                              register __a1 Msg    msg )
  16. {
  17.     Object *newobj;
  18.     ULONG   retval;
  19.  
  20.     switch(msg->MethodID) {
  21.     case OM_NEW:
  22.         /*
  23.          * pass this to the superclass first, and when it comes back,
  24.          * we will have all our data allocated (instance data).
  25.          */
  26.         if( newobj = (Object *) DSM(class, obj, msg) ) {
  27.             /*
  28.              * Initialize instance data and parse the attribute list.
  29.              */
  30.  
  31.             Skeleton_setattrs(class, newobj, (struct opSet *) msg);
  32.         }
  33.         /*
  34.          * return the new object (we may be a superclass to someone.)
  35.          */
  36.         retval = (ULONG) newobj;
  37.         break;
  38.  
  39.     case OM_SET:
  40.         /*
  41.          * call the set attributes function.
  42.          */
  43.         retval = Skeleton_setattrs(class, newobj, (struct opSet *)msg);
  44.         break;
  45.  
  46.     case OM_GET:
  47.         /*
  48.          * call the getattr function if needed. This funciton should
  49.          * default to the superclass _IF_ it cannot handle the request.
  50.          */
  51.  
  52.     case OM_DISPOSE:
  53.         /*
  54.          * Dispose of any extra objects or allocations made on the
  55.          * OM_NEW call.
  56.          */
  57.  
  58.     default:
  59.         /*
  60.          * unknown method, send it up to the superclass.
  61.          */
  62.         retval = DSM(class, obj, msg);
  63.  
  64.     }
  65.  
  66.     return(retval);
  67. }